package ptvv;

import java.util.*;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

class Blocked extends Thread {
	private BlockingQueue<String> eventQueue = new LinkedBlockingQueue<String>(); // start

	public Blocked() {

		System.out.println("Starting Blocked");
		start();
	}

	public void run() {
		try {

			eventQueue.take(); // Blocks

		} catch (InterruptedException e) {
			System.out.println("Interrupted");
		}
		System.out.println("Exiting run()");
	}
}

public class Interrupt {
	static Blocked blocked = new Blocked();

	public static void main(String[] args) {
		new Timer(true).schedule(new TimerTask() {
			public void run() {
				System.out.println("Preparing to interrupt");
				blocked.interrupt();
				blocked = null; // to release it
			}
		}, 2000); // run() after 2000 milliseconds
	}
} // /:~

